using UnityEngine;

public class CenterBone : MonoBehaviour
{
	private Rigidbody2D rb;

	private Animator at;

	private void Awake()
	{
		rb = GetComponent<Rigidbody2D>();
		at = GetComponentInParent<Animator>();
	}

	private void OnCollisionEnter2D(Collision2D collision)
	{
		if (rb.velocity.y > 6f && !at.enabled)
		{
			Generator.instance.SpawnObj(5, new Vector2(rb.position.x, 0f));
			Generator.instance.SpawnObj(2, new Vector2(rb.position.x, 0.2f));
			Generator.instance.SpawnObj(6, new Vector2(rb.position.x, 1f));
			Audio.instance.sfx[22].Play();
			Cam.instance.Shake(0.1f, 0.2f);
		}
	}
}
